//package hasthi.container.p2p;
//import rice.p2p.commonapi.Application;
//import rice.p2p.commonapi.Endpoint;
//import rice.p2p.commonapi.Id;
//import rice.p2p.commonapi.Message;
//import rice.p2p.commonapi.Node;
//import rice.p2p.commonapi.NodeHandle;
//import rice.p2p.commonapi.RouteMessage;
//import rice.p2p.scribe.ScribeClient;
//import rice.p2p.scribe.ScribeContent;
//import rice.p2p.scribe.ScribeImpl;
//import rice.p2p.scribe.Topic;
//import rice.pastry.commonapi.PastryIdFactory;
//
//
//
//public class P2PApp implements Application,ScribeClient{
//
//    /**
//     * The Endpoint represents the underlieing node.  By making calls on the 
//     * Endpoint, it assures that the message will be delivered to a MyApp on whichever
//     * node the message is intended for.
//     */
//    protected Endpoint endpoint;
//    protected ScribeImpl myScribe;
//    protected Topic myTopic;
//
//    public P2PApp(Node node) {
//      // We are only going to use one instance of this application on each PastryNode
//      this.endpoint = node.buildEndpoint(this, "myinstance");
//      
//      // the rest of the initialization code could go here
//      this.endpoint.setDeserializer(new XmlMessageDeserializer());
//      
//      myScribe = new ScribeImpl(node,"myScribeInstance");
//
//      // construct the topic
//      myTopic = new Topic(new PastryIdFactory(node.getEnvironment()), "admin");
//      
//      
//      // now we can receive messages
//      this.endpoint.register();
//      myScribe.subscribe(myTopic, this);
//    }
//    
//    public void deliver(Id id, Message message) {
//        System.out.print("Recived message "+ message + " to "+ id);
//    }
//
//    public boolean forward(RouteMessage arg0) {
//        return true;
//    }
//
//    public void update(NodeHandle arg0, boolean arg1) {
//    }
//    
//    public void sendMessage(Id recipient, Message message){
//        System.out.println("Send message  "+ message + "from "+ endpoint.getId() + " to "+ recipient);
//        endpoint.route(recipient, message, null);
//    }
//    
//
//    
//    /** methods for mulicasting **/
//    public void mulitiCast(XmlMultiCastMessage message){
//        myScribe.publish(myTopic, message);
//    }
//    
//    public void deliver(Topic topic, ScribeContent content) {
//        System.out.println("Recive a Mulicast message "+ content);
//      }
//
//    public boolean anycast(Topic arg0, ScribeContent arg1) {
//        return false;
//    }
//
//    public void childAdded(Topic arg0, NodeHandle arg1) {
//    }
//
//    public void childRemoved(Topic arg0, NodeHandle arg1) {
//    }
//
//    public void subscribeFailed(Topic arg0) {
//    }
//}
//
